
<?php
/**
  * Musashi - A project manager for music groups and bands
  * Copyright (C) 2010 Daniel Torres
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  */

/**
 * Displays a default record list of the requested table
 *  
 * @package Musashi
 * @author Daniel Torres
 */
 
 // Make sure we have access to this page
 defined('_JEXEC') or die ('Restricted access. Sorry');
 
 // Handle wrong data queries
 if($this->dataRows == null)
 {
    ?>
        <h1>Error: Wrong data call</h1>
    <?php
 }
 else
 {
    // Count the number of results
    $rowCount = count($this->dataRows);
    $fieldCount = count($this->fieldNames);
    if($rowCount == 0)
    {
       ?>
       <h1>No records yet. Click New to start!</h1>
       <?php
    }
    else
    {
       ?>
           <form action="index.php" method="post" name="adminForm">
           <table class="adminlist">
           <thead>
               <th width="20">
                   <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo $rowCount; ?>);" />
               </th>
           <?php
               // Table head: One entry per array item
               for( $i=0; $i < $fieldCount; $i++ )
               {
                   ?>
                   <th width="<?php echo $this->fieldWidths[$i] ?>">
                       <?php echo $this->fieldNames[$i] ?>
                   </th>
                   <?php
               }
           ?>
           </thead>
           <?php
            $k = 0;
            for( $i = 0; $i < $rowCount; $i++ )
            {
                $row =& $this->dataRows[$i];
                $checked = JHTML::_('grid.id', $i, $row->idVenue );
                ?>
                <tr class="<?php echo "row$k"; ?>">
                    <td>
                      <?php echo $checked; ?>
                    </td>
                    <?php
                    for( $j = 0; $j < $fieldCount; $j++)
                    {
                      ?>
                        <td>
                            <?php echo $row->name; ?>
                        </td>
                      <?php
                    }
                    ?>
                </tr>
                <?php
                $k = 1 - $k;
            }        
           ?>
           
           <?php // These must always be here ?>
           <input type="hidden" name="task" value="" />
           <input type="hidden" name="boxchecked" value="0" />
           </form>
       <?php
    }
 }
?>
